Alloy.Globals.Map = require('ti.map');

function doClick(e) {
    alert($.label.text);
}

Ti.API.info('seeded: ' + Ti.App.Properties.hasProperty('seeded2'));
//determine if the database needs to be seeded
if (!Ti.App.Properties.hasProperty('seeded2')) {
	
    // add all items to collection
    Alloy.Collections.IncidenteTO.reset([{
        "empresa": "Solventa",
		"nivel": "Critico",
		"detalle": "Contact Center",
		"fecha": "22 Jul 2014 - 12:05",
		"imagenNivel": "/assets/android/icon-open.png"
    }, {
        "empresa": "Corporativo",
		"nivel": "Critico",
		"detalle": "Correo",
		"fecha": "21 Jul 2014 - 12:05",
		"imagenNivel": "/assets/android/icon-open.png"
    }, {
        "empresa": "Oncovida Chile",
		"nivel": "Critico",
		"detalle": "OIS",
		"fecha": "17 Jul 2014 - 12:05",
		"imagenNivel": "/assets/android/icon-ok.png"
    }, {
        "empresa": "Socofar",
		"nivel": "Critico",
		"detalle": "RF",
		"fecha": "10 Jul 2014 - 12:05",
		"imagenNivel": "/assets/android/icon-open.png"
    } 
    ]);

    // save all of the elements
    Alloy.Collections.IncidenteTO.each(function(_m) {
        _m.save();
    });
	
    Ti.App.Properties.setString('seeded2', 'yuppers');

    $.index.open();

} else {
	
    $.index.open();
}

// force tables to update
Alloy.Collections.IncidenteTO.fetch();


